//
//  MineViewController.m
//  Travelling Together
//
//  Created by lanou3g on 15/11/26.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "MineViewController.h"
#import "UserHandle.h"
#import "UserTableViewCell.h"
@interface MineViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableview;
@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
      CGRect rect1 =CGRectMake(0, 44, self.view.bounds.size.width, self.view.bounds.size.height);
    self.tableview =[[UITableView alloc]initWithFrame:rect1 style:UITableViewStyleGrouped];
    
    self.tableview.delegate = self;
    self.tableview.dataSource =self;
    [self.view addSubview:self.tableview];
    
    
    
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
    [self.tableview registerClass:[UserTableViewCell class] forCellReuseIdentifier:@"ucell"];
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    if ([UserHandle shareUser].isUserLogin) {
         self.navigationItem.title = @"我";
        
    }
    else {
        self.navigationItem.title = @"未登录";
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark tableview
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.section) {
        case 0:
            return 104;
            break;
        case 1:
            return 40;
            break;
        default:
            return 0;
            break;
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    switch (section) {
        case 0:
            return 1;
            break;
        case 1:
           return 3;
            break;
        default:
            return 0;
            break;
    }
    
    
    }
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.section) {
        case 0:
        {
            
            if ([UserHandle shareUser].isUserLogin) {
                
                
                UserTableViewCell * ucell =[tableView dequeueReusableCellWithIdentifier:@"ucell" forIndexPath:indexPath];
                return ucell;
                
            }
            else
            {
                UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
                cell.textLabel.text = @"测试";
                return cell;
            }
        }
            break;
            
        case 1:
        {
        
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
            cell.textLabel.text = @"测试";
            return cell;
        
        
        
        
        }
            break;
        default:
            return nil;
            break;
    }
    
    
    

    
}
@end
